﻿CREATE proc [dbo].[thuan_qtsuanguoidung]          
@MaNV as nvarchar(255),            
@TenNV as nvarchar(255),            
@DoUuTien as int,            
@MaPB as varchar(55),        
@ChuKy as image =null    ,               
@MaChucVu as int      ,    
@UserID as int   ,    
@DuongDan as nvarchar(1000)    
 as           
declare @dem as int           
select @dem=COUNT(*) from DanhMuc_NguoiDung where UserID<>@UserID   and MaNV=@MaNV        
if(@dem =0)          
begin          
          
          
           
if(@DuongDan ='' or @DuongDan is null)          
begin          
update DanhMuc_NguoiDung set    
MaNV =@MaNV,            
TenNV =@TenNV,            
DoUuTien =@DoUuTien,            
MaPB =@MaPB,        
          
MaChucVu =@MaChucVu   
 Where UserID=@UserID        
end          
          
else          
begin          
update DanhMuc_NguoiDung set    
MaNV =@MaNV,            
TenNV =@TenNV,            
DoUuTien =@DoUuTien,            
MaPB =@MaPB,        
ChuKy =@ChuKy    ,               
MaChucVu =@MaChucVu   
 Where  UserID=@UserID          
end          
          
          
          
select ErrCode=1          
end          
else          
begin          
select ErrCode=0          
end           